package com.marketingexpert.service.marketingmgnt;

import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;

import com.marketingexpert.config.Placeholder;
import com.marketingexpert.domain.AutoFollowsFans;
import com.marketingexpert.domain.AutoRecomment;
import com.marketingexpert.domain.AutoatContent;
import com.marketingexpert.domain.Discount;
import com.marketingexpert.domain.Trend;
import com.marketingexpert.domain.User;
import com.marketingexpert.domain.UserFuncEnable;
import com.marketingexpert.domain.UserFuncEnableWeiboId;
import com.marketingexpert.exception.MarketingExpertException;
import com.marketingexpert.service.storemgnt.AbstractActivity;
import com.marketingexpert.service.storemgnt.MarketingItem;
import com.marketingexpert.service.storemgnt.MarketingPromotion;
import com.taobao.api.domain.Activity;
import com.taobao.api.domain.Coupon;
import com.taobao.api.domain.Item;
import com.taobao.api.domain.Meal;

public interface MarketingService {
	
	/**
	 * ����ԽתԽ���Ļ
	 * @param params
	 * @throws MarketingExpertException
	 */
	public void publishRetweetMarketing(Map<String, Object> params) throws MarketingExpertException;
	
	/**
	 * ����һ���Զ��Ƽ�����
	 * @param ar
	 * @return
	 * @throws MarketingExpertException
	 */
	public int saveAutoRecomment(AutoRecomment ar) throws MarketingExpertException;

	/**
	 * ���id��ѯһ���Զ��Ƽ�����������
	 * @param autoRecId
	 * @return
	 */
	public AutoRecomment queryAutoRecommentById(int autoRecId) throws MarketingExpertException;
	
	/**
	 * ���һ��Ҫ���͵���Ϣ�б�
	 * @param items
	 * @param content
	 * @param placeholder
	 * @return
	 */
	public List<String> genarateContentList(List<Item> items,
			String content, Placeholder placeholder);
	
	/**
	 * ���һ����Ϣ
	 * @param content
	 * @return
	 */
	public String generateContent(String content, AbstractActivity activity ,Placeholder placeholder);
	
	/**
	 * �Ƽ�һ����Ʒ���Ż���Ϣ
	 * @param content
	 * @param weiboUser
	 * @param mp
	 * @return
	 */
	public boolean recommentItemPromotion(String content, User weiboUser,MarketingPromotion mp,Placeholder placeholder); 
	
	/**
	 * ������Ʒ�Ƽ�
	 * @param conent
	 * @param issendTopublic �Ƿ��͵�����΢��
	 */
	public boolean sendItemRecomment(String content,User weiboUser,Item Item,Placeholder placeholder);

	/**
	 * ȡ��һ�����ڿ�ʼ�ĵ����Ż�ȯ�
	 * @param activityId
	 * @param sessionKey
	 */
	public void cancelActivity(String activityId, String sessionKey);

	/**
	 * ��ѯ�û����е��Զ��Ƽ�ģ��
	 * @param parentUserId
	 * @return
	 */
	public AutoRecomment queryAutoRecommentByUserId(int parentUserId);

	/**
	 * �����û����е��Զ��Ƽ�ģ��
	 * @param ar
	 * @return
	 */
	public int updateAutoRecomment(AutoRecomment ar);

	/**
	 * ��ѯ�����
	 * @param activityId
	 * @param sessionKey
	 * @return ��Լ���һ�����Żݾ�
	 */
	public Map<String,Object> querySingleActivity(String activityId, String sessionKey);
	
	/**
	 * ��ѯ�Żݾ���Ϣ
	 */
	public List<Coupon> getExistCoupon(String couponId, long pageNo, String sessionKey);

	/**
	 * �����Żݾ���ȡ�
	 * @param couponId
	 * @param totalNum
	 * @param maxGet
	 * @param sessionkey
	 * @return
	 */
	public AbstractActivity createCouponActivity(String couponId,
			String totalNum, String maxGet, String sessionkey);
	
	/**
	 * ������ȡ�����Ӧ���Żݾ�
	 * @param activityId
	 * @param sessionKey
	 * @return
	 */
	public List<AbstractActivity> batchQueryActivity(String activityId,String sessionKey) throws MarketingExpertException;

	/**
	 * ������ȡһ�鱦�����Ż�
	 * @param itemIds
	 * @param sessionKey
	 * @param proPageNo 
	 * @return
	 */
	public List<MarketingPromotion> batchGetItemPromotion(String[] itemIds,String sessionKey, long proPageNo);


	/**
	 * ��ȡ�����������Ż�
	 * @param itemId
	 * @param sessionKey
	 * @return
	 */
	public MarketingPromotion getItemPromotion(String itemId,String sessionKey,long pageNo);

	/**
	 * ��ѯ�������е��ײ�
	 * @param object
	 * @param sessionKey
	 * @return
	 */
	public List<Meal> queryMeals(long mealId, String sessionKey);

	/**
	 * ������ѯ���������ײ�
	 * @param mealIdLong
	 * @param sessionKey
	 * @return
	 */
	public List<Meal> batchQueryMeals(long[] mealIdLong, String sessionKey);

	/**
	 * �Ƽ��ײ�
	 * @param meal
	 * @param weiboUser
	 * @param placeholder
	 * @param content
	 * @param item 
	 * @return
	 */
	public boolean recommentMeal(Meal meal, User weiboUser,
			Placeholder placeholder, String content, MarketingItem item);

	/**
	 * ��ȡһ������
	 * @param itemId
	 * @param sessionKey
	 * @return
	 */
	public MarketingItem getSingleItem(long itemId, String sessionKey);

	/**
	 * �����Զ�Ӫ����
	 * @param trends
	 * @param weiboUserIds
	 * @param parentUserID
	 */
	public void saveAutoMarketingTrends(String[] trends, String[] weiboUserIds,
			String parentUserID) throws MarketingExpertException;
	
	
	public  List<Trend> queryAllTrendByUserId(int[] userIds,int index) throws MarketingExpertException;
	
	/**
	 * 从新浪微博查询自动营销的微博素材
	 * @param uid 用于查找的微博用户的id列表
	 * @return
	 * @throws MarketingExpertException
	 */
	public Map<String,Object> getOneTrendMessage(String uids) throws MarketingExpertException;
	
	public String autoMarketingExecute(Map<String,Object> material,User user) throws MarketingExpertException;

	/**
	 * 
	 * @param user
	 * @return
	 */
	public List<com.marketingexpert.service.snsmgnt.User> getNewFans(User user);

	public int saveAutoFollowedFans(AutoFollowsFans autoFollowsFnas) 	throws MarketingExpertException ;
	
	public boolean deleteAutoFollowedFansByPid(int parentUserId)  	throws MarketingExpertException ;
	
	public List<AutoFollowsFans> queryAllAutoFollowFansByPId(int parentUserId, int pageNo) 	throws MarketingExpertException;

	public int queryNewFansCount(int id);
	
	/**
	 * ��ȡ����΢����ת����
	 * @param messageId
	 * @return
	 */
	public int getSingleWeiboRtCounts(User user,String messageId) throws MarketingExpertException ;
	
	/**
	 * ͳ��һ��΢����ת�����,�޸���Ʒ�۸�
	 * @param rtCounts
	 * @param discounts
	 * @throws MarketingExpertException
	 */
	public void analysisWeiboRt(Discount discount)  throws MarketingExpertException;
	
	/**
	 * ��ѯ�û��Ѿ������˵Ļ���
	 * @param id
	 * @return
	 */
	public List<Trend> queryAllTrendByPId(int id);

	public void cancelAutoMarketing(int id);
	
	
	/**
	 * �����û��趨���Զ��ʺ�����
	 * @param atContent
	 * @return
	 */
	public int saveAutoAtContent(AutoatContent atContent);
	
	/**
	 * ��ѯ�û����Ƶ�@����
	 * @param pId
	 * @return
	 */
	public AutoatContent queryAtcontent(int pId);
	
	/**
	 * ����һ���û����Ƶ��Զ�@����
	 * @param atContent
	 * @return
	 */
	public int updateAtcontent(AutoatContent atContent);

	/**
	 * ȡ��һ���û����Ƶ��Զ�@����
	 * @param atContent
	 * @return
	 */
	public void cancelAutoAtContent(int parseInt);

	public void saveFuncEnable(UserFuncEnable ufe);

	/**
	 * ��ѯ�û��Ѿ������˵Ĺ���
	 * @param funcCode
	 * @param id
	 * @return
	 */
	public UserFuncEnable queryEnabledFunc(String funcCode, int userId);

	public void disableFunc(int parseInt,int userId);

	public void updateFunc(List<UserFuncEnableWeiboId> userFuncEnableWeiboIds, int pid);

	public int enableAutoAt(UserFuncEnable ufe);

	public void disableAutoAt(int parseInt);

	public int queryEnableFuncTotalCounts(String string);
	
	/**
	 * ��ҳ��ѯ �û����õĹ���
	 * @param funcCode
	 * @param cursor
	 * @param pageSize
	 * @return
	 */
	public List<UserFuncEnable> queryEnabledFuncPagin(String funcCode, int cursor, int pageSize);

	/**
	 * ��ѯһ�����ҵ��������е��Żݾ���ȡ�
	 * @param object
	 * @param sessionKey
	 * @return
	 */
	public List<Activity> getActivity(String activityId, String sessionKey);
	
}
